package com.pdd.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@Configuration
@EnableWebMvc
// @ComponentScan(basePackages = {"com.pdd.controller"})
public class SwaggerConfig {

    // 构建一个平台
    @Bean
    public Docket api(){
        ApiInfo apiInfo = getApiInfo();

        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .build()
                .apiInfo(apiInfo);
    }

    // 配置平台信息
    private ApiInfo getApiInfo(){
        ApiInfoBuilder builder = new ApiInfoBuilder();

        builder.title("拼多多购物系统API测试平台");
        builder.description("拼多多API测试平台");
        builder.version("v1.0");

        return builder.build();
    }

}
